package com.example.lvsuo.controller;


import com.example.lvsuo.entity.LogJob;
import com.example.lvsuo.entity.LogType;
import com.example.lvsuo.modal.Result;
import com.example.lvsuo.service.ILogJobService;
import com.example.lvsuo.service.ILogTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 日志类型 前端控制器
 * </p>
 *
 * @author 心心念念
 * @since 2021-03-30
 */
@RestController
@RequestMapping("/logType")
public class LogTypeController {
    @Autowired
    ILogTypeService iLogTypeService;

    /**
     * 查询日志类型
     * @return
     */
    @GetMapping
    public Result getLogType(){
        List<LogType> list = iLogTypeService.getLogType();
        return Result.back("ok","200",list);
    }

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result getLogErTypeId(@PathVariable String id){
        List<LogType> list = iLogTypeService.getLogTypeId(id);
        return Result.back("ok","200",list);
    }

    @PostMapping
    public Result addLogType(@RequestBody LogType logType){
        iLogTypeService.save(logType);
        return Result.back("ok","200");
    }

}

